﻿@using AP.Framework.Infrastructure.Repositories
@using AP.Framework.Infrastructure.Database
@using AP.Framework.Infrastructure.Entities
<div class="span3">
    <div class="well sidebar-nav">
        @*  <ul class="nav nav-list">
            <li class="nav-header">导航</li>
            <li class="active"><a href="#"><i class="icon-white icon-home"></i>首页</a></li>
            <li><a href="#"><i class="icon-cog"></i>系统设置</a></li>
            <li class="divider"></li>
            <li class="nav-header">栏目管理</li>
            <li><a href="#"><i class="icon-list"></i>栏目列表</a></li>
            <li class="divider"></li>
            <li class="nav-header">新闻管理</li>
            <li><a href="#"><i class="icon-file"></i>新闻分类</a></li>
            <li><a href="#"><i class="icon-list"></i>新闻列表</a></li>
            <li class="divider"></li>
            <li class="nav-header">产品管理</li>
            <li><a href="#"><i class="icon-file"></i>产品分类</a></li>
            <li><a href="#"><i class="icon-list"></i>产品列表</a></li>
            <li class="divider"></li>
            <li class="nav-header">人才招聘</li>
            <li><a href="#"><i class="icon-file"></i>职位分类</a></li>
            <li><a href="#"><i class="icon-list"></i>招聘列表</a></li>
            <li class="divider"></li>
            <li class="nav-header">友情链接</li>
            <li><a href="#"><i class="icon-list"></i>友情链接列表</a></li>
            <li class="divider"></li>
            <li><a href="#"><i class="icon-flag"></i>系统帮助</a></li>
        </ul>*@
        @{
            ApContext context = new ApContext();
            ModulesRepository modules = new ModulesRepository(context);
            var data = modules.GetAll().OrderBy(p => p.Sequence).ToList();
            int i = 0;   //有根结点时   
            var builder = new AP.Framework.Utilities.Utilities.Mvc.TreeBuilder<sys_Modules, int>(data,
                      p => p.ID,
                      p => p.ParentID,
                      (p, isLeaf) =>
                      {
                          i++;
                          string childnames = "child" + i;
                          string s = string.Empty;
                          if (isLeaf)
                          {
                              s += "<a href=\"" + Url.Action(p.ModuleAction, p.ModuleController, p.ModuleArea) + "\"><i class=\"" + p.ModuleIcon + "\"></i>";
                              s += p.ModuleName;
                              s += "</a>";
                          }
                          else
                          {
                              s += "<li class=\"divider\"></li>";
                              s += "<i class=\"" + p.ModuleIcon + "\"></i>";
                              s += p.ModuleName;

                          }
                          return s;

                      }, 0
                   );

            builder.NodeCssClass = "nav-header";           
        }
        @Html.Raw(builder.ToString(new { @class = "nav nav-list" }))
    </div>
    <!--/.well -->
</div>
